using Game;

namespace SCIENEW {
    /// <summary>
    /// 有6个朝向的机器
    /// </summary>
    public abstract class SixDirectionalDevice : DefaultDevice {
        protected int FrontSlot, BackSlot, SideSlot;

        public SixDirectionalDevice(string id, int frontSlot, int backSlot = 107, int sideSlot = 107) : base(id) {
            FrontSlot = frontSlot;
            BackSlot = backSlot;
            SideSlot = sideSlot;
        }
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult) {
            return new BlockPlacementData  { Value = DevicesBlockManager.GetDeviceValue(Id, DevicesUtils.GetDirectionXYZ(componentMiner)), CellFace = raycastResult.CellFace };
        }

        public override bool IsFaceTransparent(SubsystemTerrain subsystemTerrain, int face, int value) => false;

        public override int GetFaceTextureSlot(int face, int value) {
            if (face == DevicesUtils.GetInnerData(value)) return FrontSlot;
            if (face == CellFace.OppositeFace(DevicesUtils.GetInnerData(value))) return BackSlot;
            return SideSlot;
        }
    }
}